// 写文件
const fs = require('node:fs/promises')
const path = require('node:path')

// dirname 当前文件的文件路径
// const fileName = path.resolve(__dirname, './test.txt')
// process.cwd() node命令运行的文件路径 
const fileName = path.resolve(process.cwd(), './testa.txt')

// fs.writeFile('test.txt', '这是我的测试3213', {
//     encoding: 'utf-8',
//     flag: 'a'
// })

fs.writeFile(fileName, Buffer.from('这是我的测试3213'), {
    encoding: 'utf-8',
    flag: 'a'
})